#include "srv_threads.h"
#include "os_user.h"
#include "portmacro.h"
#include "task.h"
#include "Ifx_Lwip.h"



#define  geth_netif_input_              ethernetif_input
#define  tcp_thread_                    tcpip_thread

#define  tcpip_input_                   tcpip_input
#define  ethernet_input_                ethernet_input
#define  etharp_input_                  etharp_input
#define  etharp_raw_                    etharp_raw
#define  ethernet_output_               ethernet_output
#define  low_level_output_              low_level_output

#define  Ifx_Lwip_printf_               Ifx_Lwip_printf

#define  ifx_netif_init_                ifx_netif_init
#define  ifx_lwip_init_                 Ifx_Lwip_init
#define  tcpip_init_                    tcpip_init
#define  low_level_init_                low_level_init

#define xQueueCreateCountingSemaphore_  xQueueCreateCountingSemaphore
#define sys_thread_new_                 sys_thread_new

#define ISR_Geth_Rx_                    ISR_Geth_Rx


/* Function to initialize the LED */

extern int flg_int;
int task1_last_waketime = 0;
void task1_led(void *arg)
{
    TickType_t xLastWakeTime;
    (void)arg;
    xLastWakeTime = xTaskGetTickCount();
    task1_last_waketime = xLastWakeTime;
    while (1)
    {
        vTaskDelayUntil(&xLastWakeTime, pdMS_TO_TICKS(OS_DEMO_CONTROL_TASK1_PERIOD_MS));
        {
            Ifx_Lwip_pollTimerFlags();                          /* Poll LwIP timers and trigger protocols execution if required */
            drv_led0_toggle();
            flg_int = 0;
        }
    }
}
void task2_led(void *arg)
{
    TickType_t xLastWakeTime;
    (void)arg;
    xLastWakeTime = xTaskGetTickCount();
    while (1)
    {
        vTaskDelayUntil(&xLastWakeTime, pdMS_TO_TICKS(OS_DEMO_CONTROL_TASK2_PERIOD_MS));
        {
            drv_led1_toggle();
            flg_int = 0;
        }
    }

}

void task3_led(void *arg)
{
    TickType_t xLastWakeTime;
    (void)arg;
    xLastWakeTime = xTaskGetTickCount();
    while (1)
    {
        vTaskDelayUntil(&xLastWakeTime, pdMS_TO_TICKS(OS_DEMO_CONTROL_TASK3_PERIOD_MS));
        {
//            drv_led2_toggle();
            flg_int = 0;
        }
    }

}


